#include "SslMain.h"
using namespace spt;
#include "windows.h"

handle spt::SemaphoreB::Creat()
{
    return sem = CreateSemaphore(0, 0, 1, 0);
}

spt::SemaphoreB::SemaphoreB()
{
    sem = 0;
}

spt::SemaphoreB::~SemaphoreB()
{
    if (sem)
    {
        CloseHandle(sem);
    }
}

int32 spt::SemaphoreB::Wait(int32 timeOut)
{
    if (timeOut == -1)
    {
        timeOut = INFINITE;
    }
    
    return int32(WaitForSingleObject(sem, timeOut));
}

int32 spt::SemaphoreB::Post()
{
    return int32(ReleaseSemaphore(sem,1,0));
}
